home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Freeware / Griffith 0.9.8 / griffith-0.9.8-win32.exe / {app} / lib / plugins / movie / PluginMovieCineteka.py < prev    next >
Text File  |  2008-11-17  |  5KB  |  152 lines

  1. # -*- coding: UTF-8 -*-
  2.  
  3. __revision__ = '$Id: PluginMovie7arte.py 478 2006-12-05 21:14:51Z piotrek $'
  4.  
  5. # Copyright (c) 2005-2007 Vasco Nunes, Piotr Ozarowski
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. # GNU Library General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  20.  
  21. # You may use and distribute this software under the terms of the
  22. # GNU General Public License, version 2 or later
  23.  
  24. import gutils
  25. import movie
  26. import string
  27.  
  28. plugin_name = "Cineteka"
  29. plugin_description = "O seu Clube de Video Online"
  30. plugin_url = "cineteka.com"
  31. plugin_language = _("Portuguese")
  32. plugin_author = "Vasco Nunes"
  33. plugin_author_email = "<vasco.m.nunes@gmail.com>"
  34. plugin_version = "0.3"
  35.  
  36. class Plugin(movie.Movie):
  37.     """A movie plugin object"""
  38.     def __init__(self, id):
  39.         self.encode='iso-8859-1'
  40.         self.movie_id = id
  41.         self.url = "http://www.cineteka.com/index.php?op=Movie&id=" + str(self.movie_id)
  42.  
  43.     def get_image(self):
  44.         """Finds the film's poster image"""
  45.         self.image_url = "http://www.cineteka.com/img/filmes/" + str(self.movie_id) + "_big.jpg"
  46.  
  47.     def get_o_title(self):
  48.         """Finds the film's original title"""
  49.         self.o_title = string.capwords(gutils.trim(self.page, """<nobr><span class="txt11">(""", ")"))
  50.  
  51.     def get_title(self):
  52.         """Finds the film's local title.
  53.         Probably the original title translation"""
  54.         self.title = string.capwords(gutils.trim(self.page, """<td class="txt12"><b>""", "</b>"))
  55.  
  56.     def get_director(self):
  57.         """Finds the film's director"""
  58.         self.director = gutils.strip_tags(gutils.trim(self.page, "<div><b>Realiza├º├úo:</b><br>", "</div>"))
  59.         self.director = string.replace(self.director,"<br>", ", ")
  60.         self.director = gutils.strip_tags(self.director)
  61.  
  62.     def get_plot(self):
  63.         """Finds the film's plot"""
  64.         self.plot = gutils.trim(self.page, """<div class="txt-normal" style="margin-top: 10px;">""", "</td></tr></table>")
  65.  
  66.     def get_year(self):
  67.         """Finds the film's year"""
  68.         self.year = gutils.trim(self.page, "<b>Ano:</b> ", "</div>")
  69.  
  70.     def get_runtime(self):
  71.         """Finds the film's running time"""
  72.         self.runtime = gutils.trim(self.page, "<td><b>Dura├º├úo:</b> ", " min.</td>")
  73.  
  74.     def get_genre(self):
  75.         """Finds the film's genre"""
  76.         self.genre = gutils.strip_tags(gutils.trim(self.page, "<b>G├⌐nero:</b><br>", "</div>"))
  77.         self.genre = string.replace(self.genre,"<br>", ", ")
  78.         self.genre = gutils.strip_tags(self.genre)
  79.  
  80.     def get_cast(self):
  81.         self.cast = gutils.strip_tags(gutils.trim(self.page, "<b>Elenco:</b> ", "</td>"))
  82.         self.cast = string.replace(self.cast, ", ", "")
  83.         self.cast = string.replace(self.cast, "\t", "")
  84.         self.cast = string.replace(self.cast, "\n ", "\n")
  85.  
  86.     def get_classification(self):
  87.         """Find the film's classification"""
  88.         self.classification = gutils.trim(self.page, "<b>Idade:</b> ", "</div>")
  89.  
  90.     def get_studio(self):
  91.         """Find the studio"""
  92.         self.studio = ""
  93.  
  94.     def get_o_site(self):
  95.         """Find the film's oficial site"""
  96.         self.o_site = gutils.trim(self.page, \
  97.             "<a class=\"button\" href=\"", \
  98.             " title=\"Consultar t├¡tulo no Internet Movie Data Base\"")
  99.  
  100.     def get_site(self):
  101.         """Find the film's imdb details page"""
  102.         self.site = gutils.trim(self.page, \
  103.             "</td><td><a class=\"button\" href=\"", \
  104.             """" title="Consultar t├â┬¡tulo""")
  105.  
  106.     def get_trailer(self):
  107.         """Find the film's trailer page or location"""
  108.         self.trailer = ""
  109.  
  110.     def get_country(self):
  111.         """Find the film's country"""
  112.         self.country = gutils.trim(self.page, "<b>Pa├¡s:</b><br>", "</div>")
  113.         self.country = string.replace(self.country,"<br>", ", ")
  114.         self.country = gutils.strip_tags(self.country)
  115.  
  116.     def get_rating(self):
  117.         """Find the film's rating. From 0 to 10.
  118.         Convert if needed when assigning."""
  119.         self.rating = 0
  120.  
  121. class SearchPlugin(movie.SearchMovie):
  122.     """A movie search object"""
  123.     def __init__(self):
  124.         self.original_url_search = "http://www.cineteka.com/index.php?op=MovieSearch&s="
  125.         self.translated_url_search = self.original_url_search
  126.         self.encode='iso-8859-1'
  127.  
  128.     def search(self, parent_window):
  129.         """Perform the web search"""
  130.         self.open_search(parent_window)
  131.         self.sub_search()
  132.         return self.page
  133.  
  134.     def sub_search(self):
  135.         """Isolating just a portion (with the data we want) of the results"""
  136.         self.page = gutils.trim(self.page, \
  137.             """o:</div>""", """<div style="margin-top: 10px; text-align: center;"></div>""")
  138.  
  139.     def get_searches(self):
  140.         """Try to find both id and film title for each search result"""
  141.         elements = string.split(self.page, "</a>]</td>")
  142.         self.number_results = elements[-1]
  143.  
  144.         if (elements[0]<>''):
  145.             for element in elements:
  146.                 self.ids.append(gutils.trim(element, "?op=Movie&id=", "\""))
  147.                 self.titles.append(gutils.strip_tags(gutils.convert_entities \
  148.                     (gutils.trim(element, """<td class="txt12"><b>""", "</span></nobr></td>"))))
  149.         else:
  150.             self.number_results = 0
  151.  
  152.